<template>
  <div class="shangpinDialog">
    <el-dialog
      title="选择入库单号"
      :close-on-click-modal="false"
      :visible.sync="dialogTableVisible"
      width="75%">
      <div class="pageTop" style="padding: 10px 10px;display: flex;align-items: center;height: 50px" >
        <input style="width: 200px;margin-right: 10px" class="inputClass" v-model="queryParams.putStorageCode" type="text"  placeholder="请输入入库单号"    v-on:keyup.enter="getList" >
        <el-button type="primary" size="medium" @click="getList">搜 索</el-button>
      </div>
      <el-table
        highlight-current-row
        max-height="300"
        @row-click="rowClick"
        v-loading="loading"
        :data="rukuList"
        stripe border style="margin-top: 20px"
        :header-cell-style="{background:'#eef1f6',color:'#606266'}">
        <el-table-column  width="35">
          <template slot-scope="scope">
            <el-radio :label="scope.row.putStorageId" v-model="radioId">&nbsp;</el-radio>
          </template>
        </el-table-column>
        <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
        <el-table-column align="center" label="入库单号"   property="putStorageCode"  width="180" ></el-table-column>
        <el-table-column align="center" label="入库数量"   property="officialReceiptsCount"   ></el-table-column>
        <el-table-column align="center" label="入库名称"   property="warehouseName"   ></el-table-column>

        <!--            <el-table-column align="center" label="预计采购数量（自己计算）"   property="ren"  width="200" ></el-table-column>-->
        <!--            <el-table-column align="center" label="实际采购数量"   property="shouji"   ></el-table-column>-->
        <!--            <el-table-column align="center" label="状态"   property="shouji"   ></el-table-column>-->
        <el-table-column align="center" label="入库金额"   property="actualPaymentMoney"   ></el-table-column>
        <el-table-column align="center" label="备注"   property="remark"  show-overflow-tooltip ></el-table-column>
      </el-table>
      <el-pagination
        style="margin-top: 20px;text-align: right"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :page-sizes="[10, 20, 30, 40]"
        :current-page="queryParams.current"
        :page-size="queryParams.size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>

      <div class="pageTop" style="padding:10px;margin-top: 15px;text-align: right">
        <el-button type="primary" size="medium" @click="determine" >确 定</el-button>
        <el-button  size="medium" @click="cancel" >关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import request from '@/utils/request'
  export default {
    props: ['cgdData'],
    name: "Role",
    data() {
      return {
        putStorageCode:'',
        camgkuList:[],
        rukuList:[],
        total:0,
        radioId:'',
        loading:false,
        // 部门树选项
        deptOptions: undefined,
        defaultProps: {
          children: "child",
          label: "catName"
        },
        dataList:[],
        dialogTableVisible:true,
        queryParams:{
          isProduced :1,
          putStorageStatus:3,
          current:1,
          size:10,
          catId:0,//分类id
          goodsName:'',
          goodsSn:'',
          purchasePlan:'',
        },
        multipleSelection:[],
        rukucode:'',
      };
    },
    watch: {
      dialogTableVisible: function () {
        this.dialogTableVisible = true;//始终让他为true;
        this.cancel();//隐藏
      },
    },
    created() {
      console.log('接受',this.cgdData)
      //分类查询
      this.getcangku()
      this.getFenlei()

    },
    mounted() {

    },
    methods: {
      //获取仓库
      getcangku:function (){
        request({
          url: '/wh/warehouse/list?isAllot=1&isMaterial=1',
          method: 'get',
        }).then(response => {
          this.camgkuList = response.data
        });
      },
      //分类查询
      getFenlei:function (){
        request({
          url: '/wh/products/categoryList',
          method: 'get',
          params:this.queryParams
        }).then(response => {
          this.deptOptions =response.data
          this.getList();
        });
      },
      // 筛选节点
      filterNode(value, data) {
        if (!value) return true;
        return data.label.indexOf(value) !== -1;
      },
      // 节点单击事件
      handleNodeClick(data) {
        console.log('节点单击',data.catId)
        this.queryParams.catId = data.catId
        this.getList();
      },
      rowClick(row){
        this.radioId=row.putStorageId;
        this.ckname=row.purchasePlanName
        this.rukucode = row.putStorageCode

        console.log('单选',row)
      },
      //分页查询
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
        this.queryParams.current = val
        this.getList()
      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
        this.queryParams.size = val
        this.getList()
      },
      //搜索
      getList:function (){
        this.loading=true
        request({
          url: '/wh/putStorage/page',
          method: 'get',
          params:this.queryParams
        }).then(response => {
          this.loading=false
          if(response.code=='200'){
            this.rukuList = response.data.records
            this.total =response.data.total
          }else {
            this.rukuList=[]
            this.$message({
              type: 'warning',
              message:response.msg
            });
          }
        });

      },
      //确定
      determine:function(){
        var obj={}
        obj.radioId =  this.radioId
        obj.putStorageCode =  this.putStorageCode
        obj.rukucode = this.rukucode
        this.$emit('callback',obj)//将submitModel的值传给父组件
      },
      //隐藏
      cancel:function(){
        // this.determine()
        this.$emit('callback','')//将submitModel的值传给父组件
      },

    }
  };
</script>
<style scoped>
  .shangpinDialog {

  }



</style>
